package ch01.text00.tx05;

public class Email {
    private String email;

    // 设置邮箱地址
    public Email(String email) {
        this.email = email;
    }

    // 获取帐户名 (即邮箱的"@ "符号前的部分)
    public String getAccountName() {
        int index = email.indexOf("@");
        if (index != -1) {
            return email.substring(0, index);
        }
        return null; // 如果邮箱格式不正确
    }
}
